package com.water.bs.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.water.bs.pojo.User;
import com.water.bs.service.RankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
public class RankController {
    @Autowired
    private RankService rankService;

    @RequestMapping("/userRank")
    public JSON userRank (){
        JSONObject rs = new JSONObject();
        List<User> users = rankService.userRank();
//        for (User user : users) {
//            System.out.println(user);
//        }
        rs.put("list",users);
        return rs;
    }

    @RequestMapping("/changeRank")
    public JSON orgRank (){
        JSONObject rs = new JSONObject();
        List<Map<String, Object>> maps = rankService.changeRank();
        rs.put("list",maps);
        return rs;
    }
}
